Fractional Anisotropy Maps - Steps and Results

On Thursday, we showed Greg the output of the first step of the CAPTURE pipeline - namely, after modifying the CAPTURE MATLAB pipeline to accept TIFF files (originally it only took TIFs), we were able to generate two structure tensors from a TIFF stack of Aut1367 originally for use in Ilastik analysis. The main steps for the generation of the structure tensors are explained in a separate viewer (we showed Greg this) on Thursday: http://nbviewer.jupyter.org/github/NeuroDataDesign/seelviz/blob/gh-pages/Tony/ipynb/Generating%20Structure%20Tensors.ipynb

There were two separate structure tensors generated by the CAPTURE pipeline - one was "DTK" (which could be used later in the Diffusion ToolKit process) and the other was "FSL" (an alternate file format). We realized at office hours that the structure tensors (which were 5000 x 5000 x 5 x 6) each were the "lower triangular" values from the structures.

From there, we first tried to use the DTK file directly inside Diffusion ToolKit, but were informed that the "file appeared to be corrupted/missing data". Only the FSL format seemed to have properly saved all the image data (likely because it was run first during the MATLAB script, and because generating the structure tensors froze Tony's computer, so the DTK file format was corrupted. Thus, all analysis was done on the FSL file.

From there, we followed the DiPy tutorial/ndmg code that was suitable for generating FA maps (as recommended by Greg).


In [1]:
from dipy.reconst.dti import fractional_anisotropy, color_fa
from argparse import ArgumentParser
from scipy import ndimage
import os
import re
import numpy as np
import nibabel as nb
import sys
import matplotlib

matplotlib.use('Agg')  # very important above pyplot import
import matplotlib.pyplot as plt

In [2]:
import vtk

In [3]:
from dipy.reconst.dti import from_lower_triangular

In [4]:
img = nb.load('../../../../../Desktop/result/dogsig1_gausig2.3/v100_ch0_tensorfsl_dogsig1_gausig2.3.nii')

In [5]:
data = img.get_data()

In [6]:
# Output is the structure tensor generated from a lower triangular structure tensor (which data is)
output = from_lower_triangular(data)

Subsampling:

We added this step because the calculation of RGB/eigenvalues/eigenvectors took much too long on the full file. Even still, with small sizes like 25x25, the last VTK rendering step took significant amounts of time. In the pipeline we'll have to think of a more optimal way to compute these, and we're guessing we're missing something (since why is this taking so long)?


In [31]:
output_ds = output[4250:4300, 250:300, :, :, :]

In [32]:
print output.shape
print output_ds.shape


(5000, 5000, 5, 3, 3)
(50, 50, 5, 3, 3)

In [33]:
FA = fractional_anisotropy(output_ds)

In [34]:
FA = np.clip(FA, 0, 1)

In [35]:
FA[np.isnan(FA)] = 0

In [36]:
print FA.shape


(50, 50, 5, 3)

In [37]:
from dipy.reconst.dti import decompose_tensor

In [38]:
evalues, evectors = decompose_tensor(output_ds)

In [39]:
print evectors[..., 0, 0].shape
print evectors.shape[-2:]


(50, 50, 5)
(3, 3)

In [40]:
print FA[:, :, :, 0].shape


(50, 50, 5)

In [41]:
## To satisfy requirements for RGB
RGB = color_fa(FA[:, :, :, 0], evectors)

In [42]:
nb.save(nb.Nifti1Image(np.array(255 * RGB, 'uint8'), img.get_affine()), 'tensor_rgb_upper.nii.gz')


/Users/Tony/anaconda/lib/python2.7/site-packages/ipykernel/__main__.py:1: DeprecationWarning: get_affine method is deprecated.
Please use the ``img.affine`` property instead.

* deprecated from version: 2.1
* Will raise <class 'nibabel.deprecator.ExpiredDeprecationError'> as of version: 4.0
  if __name__ == '__main__':

In [43]:
print('Computing tensor ellipsoids in a random part')

from dipy.data import get_sphere
sphere = get_sphere('symmetric724')

from dipy.viz import fvtk


Computing tensor ellipsoids in a random part

In [44]:
ren = fvtk.ren()
evals = evalues[:, :, :]
evecs = evectors[:, :, :]

In [45]:
print "printing evals:"
print evals


printing evals:
[[[[  3.59858673e+02   4.20508653e-01   0.00000000e+00]
   [  4.05917450e+02   5.61607122e-01   7.03589618e-02]
   [  4.25848846e+02   7.01524436e-01   5.80489457e-01]
   [  4.19685120e+02   1.13140678e+00   6.51538432e-01]
   [  3.81875427e+02   1.34272110e+00   5.77863395e-01]]

  [[  3.61585938e+02   4.56072748e-01   0.00000000e+00]
   [  4.07860229e+02   6.18554890e-01   0.00000000e+00]
   [  4.27822357e+02   7.35710680e-01   4.71231312e-01]
   [  4.21525391e+02   1.06481409e+00   7.47136772e-01]
   [  3.83449982e+02   1.35440505e+00   6.66064262e-01]]

  [[  3.62073059e+02   5.12886703e-01   0.00000000e+00]
   [  4.08605103e+02   7.03238547e-01   0.00000000e+00]
   [  4.28809692e+02   8.40516150e-01   3.31217498e-01]
   [  4.22663727e+02   1.05653214e+00   8.71012688e-01]
   [  3.84584076e+02   1.45561719e+00   7.78225422e-01]]

  ..., 
  [[  3.56612427e+02   6.11936986e-01   0.00000000e+00]
   [  4.02752686e+02   7.30627954e-01   0.00000000e+00]
   [  4.23407196e+02   7.53842890e-01   0.00000000e+00]
   [  4.18378021e+02   6.73720360e-01   0.00000000e+00]
   [  3.81691772e+02   5.22040427e-01   0.00000000e+00]]

  [[  3.55404449e+02   6.03852987e-01   0.00000000e+00]
   [  4.01798859e+02   7.27090955e-01   0.00000000e+00]
   [  4.22981354e+02   7.56930351e-01   0.00000000e+00]
   [  4.18546326e+02   6.82632506e-01   0.00000000e+00]
   [  3.82286804e+02   5.33642113e-01   0.00000000e+00]]

  [[  3.55258240e+02   6.66312158e-01   0.00000000e+00]
   [  4.01925415e+02   8.15788031e-01   0.00000000e+00]
   [  4.23530853e+02   8.63975525e-01   0.00000000e+00]
   [  4.19518768e+02   7.92349696e-01   1.01134628e-01]
   [  3.83493286e+02   6.29126668e-01   1.89753234e-01]]]


 [[[  3.57809509e+02   4.67865318e-01   0.00000000e+00]
   [  4.03147339e+02   6.35834515e-01   5.17178833e-01]
   [  4.22396515e+02   1.36941564e+00   6.89541876e-01]
   [  4.15794373e+02   2.06682944e+00   6.91424310e-01]
   [  3.78013458e+02   2.34213400e+00   6.00293398e-01]]

  [[  3.59174744e+02   5.03585398e-01   0.00000000e+00]
   [  4.04815796e+02   6.71246946e-01   3.34904611e-01]
   [  4.24247070e+02   1.24392700e+00   7.66928792e-01]
   [  4.17664490e+02   2.03908420e+00   7.75722563e-01]
   [  3.79717468e+02   2.39070702e+00   6.76855505e-01]]

  [[  3.59536102e+02   5.52521169e-01   0.00000000e+00]
   [  4.05594604e+02   7.39884377e-01   2.40310207e-02]
   [  4.25470459e+02   1.01363420e+00   8.59910727e-01]
   [  4.19204742e+02   1.92192245e+00   8.74882281e-01]
   [  3.81319366e+02   2.37068915e+00   7.66683817e-01]]

  ..., 
  [[  3.54965668e+02   6.24985516e-01   0.00000000e+00]
   [  4.01175751e+02   7.57918656e-01   0.00000000e+00]
   [  4.22137238e+02   7.93716490e-01   0.00000000e+00]
   [  4.17521332e+02   7.18600869e-01   0.00000000e+00]
   [  3.81217773e+02   5.62417030e-01   0.00000000e+00]]

  [[  3.53336121e+02   5.68827510e-01   0.00000000e+00]
   [  3.99692322e+02   6.93498492e-01   0.00000000e+00]
   [  4.21115997e+02   7.31282055e-01   0.00000000e+00]
   [  4.17092255e+02   6.67581856e-01   0.00000000e+00]
   [  3.81277832e+02   5.27325153e-01   0.00000000e+00]]

  [[  3.52928040e+02   5.89172125e-01   0.00000000e+00]
   [  3.99422119e+02   7.27557421e-01   0.00000000e+00]
   [  4.21160187e+02   7.77772427e-01   1.39714861e-02]
   [  4.17512421e+02   7.19972253e-01   1.31833702e-01]
   [  3.81965759e+02   5.76425135e-01   2.01552317e-01]]]


 [[[  3.54687195e+02   5.23833692e-01   2.28979141e-01]
   [  3.99250061e+02   9.21877742e-01   6.66712403e-01]
   [  4.17898773e+02   1.80461884e+00   7.45360851e-01]
   [  4.11027313e+02   2.54443383e+00   7.27124453e-01]
   [  3.73475494e+02   2.80957508e+00   6.16639137e-01]]

  [[  3.55649628e+02   5.60207129e-01   3.85872051e-02]
   [  4.00564575e+02   7.76476085e-01   7.16372252e-01]
   [  4.19508972e+02   1.73554039e+00   8.17232072e-01]
   [  4.12788177e+02   2.56988859e+00   8.03484023e-01]
   [  3.75169983e+02   2.90267086e+00   6.84504271e-01]]

  [[  3.55939392e+02   6.00708246e-01   0.00000000e+00]
   [  4.01382874e+02   7.84672678e-01   4.76545751e-01]
   [  4.20911316e+02   1.49159718e+00   8.90556574e-01]
   [  4.14621216e+02   2.39817405e+00   8.80785048e-01]
   [  3.77112793e+02   2.80250573e+00   7.53656507e-01]]

  ..., 
  [[  3.55364838e+02   6.49586082e-01   0.00000000e+00]
   [  4.01954468e+02   7.97650516e-01   0.00000000e+00]
   [  4.23358368e+02   8.46089244e-01   0.00000000e+00]
   [  4.19102783e+02   7.76365280e-01   0.00000000e+00]
   [  3.82920593e+02   6.16245806e-01   0.00000000e+00]]

  [[  3.53148773e+02   5.50384104e-01   0.00000000e+00]
   [  3.99721344e+02   6.79358721e-01   0.00000000e+00]
   [  4.21475708e+02   7.26188004e-01   0.00000000e+00]
   [  4.17781372e+02   6.72849834e-01   0.00000000e+00]
   [  3.82162109e+02   5.40047467e-01   0.00000000e+00]]

  [[  3.52224335e+02   5.35329878e-01   1.39594942e-01]
   [  3.98760406e+02   6.67076051e-01   1.49549291e-01]
   [  4.20697632e+02   7.21261978e-01   1.48808077e-01]
   [  4.17333588e+02   6.76820755e-01   1.39819428e-01]
   [  3.82041626e+02   5.50456226e-01   1.23499222e-01]]]


 ..., 
 [[[  3.39595276e+02   8.91354561e-01   1.88191742e-01]
   [  3.83573151e+02   1.15893364e+00   3.28132153e-01]
   [  4.02730835e+02   1.31307340e+00   5.18151283e-01]
   [  3.96921417e+02   1.29334760e+00   6.87276721e-01]
   [  3.60963989e+02   1.10404134e+00   7.46736228e-01]]

  [[  3.38109436e+02   1.11758637e+00   8.03707719e-01]
   [  3.82249817e+02   1.25719190e+00   1.00777853e+00]
   [  4.01792511e+02   1.32786107e+00   1.09425449e+00]
   [  3.96424683e+02   1.28438330e+00   1.06195295e+00]
   [  3.60813293e+02   1.11512697e+00   9.16927278e-01]]

  [[  3.36890594e+02   1.75537479e+00   7.45460153e-01]
   [  3.81107300e+02   1.80357027e+00   9.44469750e-01]
   [  4.00922913e+02   1.67370188e+00   1.04015744e+00]
   [  3.95913208e+02   1.44061208e+00   9.94572282e-01]
   [  3.60617035e+02   1.15425324e+00   8.26307476e-01]]

  ..., 
  [[  3.58613037e+02   6.67148411e-01   6.20746017e-01]
   [  4.05173157e+02   9.09415662e-01   7.64757335e-01]
   [  4.25715851e+02   1.16543388e+00   8.17883253e-01]
   [  4.20050995e+02   1.34338450e+00   7.66263664e-01]
   [  3.82510895e+02   1.34672415e+00   6.27659917e-01]]

  [[  3.59222839e+02   1.49669194e+00   6.86491191e-01]
   [  4.06451874e+02   1.60874546e+00   8.36362541e-01]
   [  4.27659882e+02   1.57611930e+00   8.84308517e-01]
   [  4.22389435e+02   1.43170071e+00   8.13841283e-01]
   [  3.84808594e+02   1.19917500e+00   6.53930306e-01]]

  [[  3.58545837e+02   2.19511509e+00   7.50551939e-01]
   [  4.06261505e+02   2.21592736e+00   9.01456952e-01]
   [  4.28091949e+02   1.96338105e+00   9.41773057e-01]
   [  4.23305664e+02   1.56276453e+00   8.58080506e-01]
   [  3.85887115e+02   1.13685513e+00   6.82278574e-01]]]


 [[[  3.37472534e+02   8.95489395e-01   3.20493013e-01]
   [  3.81124512e+02   1.14060271e+00   2.40691379e-02]
   [  4.00172028e+02   1.27781463e+00   0.00000000e+00]
   [  3.94478149e+02   1.24771488e+00   0.00000000e+00]
   [  3.58846069e+02   1.05519652e+00   0.00000000e+00]]

  [[  3.36088074e+02   1.15798974e+00   7.89062619e-01]
   [  3.79846588e+02   1.14896333e+00   7.16417849e-01]
   [  3.99212158e+02   1.22976398e+00   2.30751172e-01]
   [  3.93907776e+02   1.17697525e+00   0.00000000e+00]
   [  3.58598145e+02   9.80149627e-01   0.00000000e+00]]

  [[  3.34898224e+02   1.72548282e+00   7.79910207e-01]
   [  3.78731384e+02   1.43651009e+00   9.55634773e-01]
   [  3.98380981e+02   1.15918291e+00   7.18668818e-01]
   [  3.93454132e+02   1.06966782e+00   1.10383190e-01]
   [  3.58474884e+02   8.77274871e-01   0.00000000e+00]]

  ..., 
  [[  3.56688049e+02   7.27307320e-01   6.17908359e-01]
   [  4.02922424e+02   1.06938815e+00   7.70037293e-01]
   [  4.23375244e+02   1.43306768e+00   8.40002596e-01]
   [  4.17864716e+02   1.69489312e+00   8.00248146e-01]
   [  3.80675507e+02   1.72290349e+00   6.64050996e-01]]

  [[  3.57972687e+02   1.49410093e+00   6.92057431e-01]
   [  4.04777802e+02   1.60340416e+00   8.45311821e-01]
   [  4.25700043e+02   1.56405187e+00   8.89966309e-01]
   [  4.20374237e+02   1.40984714e+00   8.12678933e-01]
   [  3.82992615e+02   1.16639090e+00   6.50406718e-01]]

  [[  3.57749969e+02   2.09966874e+00   7.47228920e-01]
   [  4.04926086e+02   2.01527023e+00   9.01064038e-01]
   [  4.26279877e+02   1.63663888e+00   9.35122073e-01]
   [  4.21250885e+02   1.16387713e+00   8.09465885e-01]
   [  3.83913727e+02   8.06572080e-01   5.23650348e-01]]]


 [[[  3.36039642e+02   9.08809602e-01   1.55218571e-01]
   [  3.79592865e+02   1.13101709e+00   0.00000000e+00]
   [  3.98764404e+02   1.24603474e+00   0.00000000e+00]
   [  3.93364807e+02   1.19976115e+00   0.00000000e+00]
   [  3.58093872e+02   1.00263965e+00   0.00000000e+00]]

  [[  3.35001892e+02   9.79336202e-01   5.35142004e-01]
   [  3.78626221e+02   1.14718246e+00   0.00000000e+00]
   [  3.98035187e+02   1.23317134e+00   0.00000000e+00]
   [  3.92933868e+02   1.16422987e+00   0.00000000e+00]
   [  3.57910248e+02   9.55571949e-01   0.00000000e+00]]

  [[  3.34022339e+02   1.16307700e+00   7.58749306e-01]
   [  3.77712555e+02   1.12263942e+00   4.50433195e-01]
   [  3.97376038e+02   1.16877949e+00   0.00000000e+00]
   [  3.92613770e+02   1.08464432e+00   0.00000000e+00]
   [  3.57880829e+02   8.77141535e-01   0.00000000e+00]]

  ..., 
  [[  3.55389343e+02   7.14470565e-01   5.28124392e-01]
   [  4.01246765e+02   1.13221836e+00   7.52724290e-01]
   [  4.21460205e+02   1.66352570e+00   8.52787852e-01]
   [  4.15919525e+02   2.08385944e+00   8.25496078e-01]
   [  3.78926758e+02   2.18585038e+00   6.90535605e-01]]

  [[  3.57592346e+02   1.30233502e+00   6.70190156e-01]
   [  4.03946594e+02   1.51516414e+00   8.14386785e-01]
   [  4.24436615e+02   1.61977875e+00   8.58548820e-01]
   [  4.18859589e+02   1.58638489e+00   7.95690060e-01]
   [  3.81494781e+02   1.40156376e+00   6.50276184e-01]]

  [[  3.58084473e+02   1.79286420e+00   7.11783409e-01]
   [  4.04743530e+02   1.75025380e+00   8.53484035e-01]
   [  4.25505768e+02   1.47778225e+00   8.58741522e-01]
   [  4.20045624e+02   1.14625728e+00   6.83443308e-01]
   [  3.82586060e+02   8.50818276e-01   4.11481380e-01]]]]

In [46]:
print "printing evecs"
print evecs


printing evecs
[[[[[  1.24202820e-03   9.98928905e-01   4.62541170e-02]
    [ -8.69421288e-04  -4.62530591e-02   9.98929381e-01]
    [  9.99998868e-01  -1.28091278e-03   8.11042497e-04]]

   [[  1.37818838e-03   9.95012462e-01   9.97410789e-02]
    [ -1.53448002e-03  -9.97389480e-02   9.95012462e-01]
    [  9.99997854e-01  -1.52436527e-03   1.38936774e-03]]

   [[  1.45453122e-03  -7.51945853e-01  -6.59223318e-01]
    [ -2.36948044e-03   6.59219563e-01  -7.51946807e-01]
    [  9.99996126e-01   2.65574688e-03  -8.22865521e-04]]

   [[  1.44273485e-03  -1.34770319e-01   9.90875840e-01]
    [ -3.16984626e-03   9.90871251e-01   1.34774312e-01]
    [  9.99993920e-01   3.33536742e-03  -1.00236328e-03]]

   [[  1.35963270e-03  -7.72602037e-02   9.97010052e-01]
    [ -3.75703746e-03   9.97003555e-01   7.72648230e-02]
    [  9.99992013e-01   3.85085586e-03  -1.06528914e-03]]]


  [[[ -1.23419065e-03   9.99839664e-01   1.78640019e-02]
    [  1.70951500e-03  -1.78618804e-02   9.99839008e-01]
    [ -9.99997795e-01  -1.26453082e-03   1.68719597e-03]]

   [[  1.35540089e-03   9.99358714e-01   3.57820243e-02]
    [ -2.25171121e-03  -3.57789174e-02   9.99357164e-01]
    [  9.99996543e-01  -1.43510045e-03   2.20177229e-03]]

   [[  1.41584885e-03   9.90882337e-01   1.34722516e-01]
    [ -2.89704255e-03  -1.34718016e-01   9.90879714e-01]
    [  9.99994814e-01  -1.79323286e-03   2.67988816e-03]]

   [[  1.39172655e-03  -1.21305786e-01   9.92614210e-01]
    [ -3.48720886e-03   9.92608547e-01   1.21309981e-01]
    [  9.99992967e-01   3.63028352e-03  -9.58421035e-04]]

   [[  1.30233588e-03  -5.12934476e-02   9.98682797e-01]
    [ -3.89758172e-03   9.98675764e-01   5.12981713e-02]
    [  9.99991536e-01   3.95925529e-03  -1.10069092e-03]]]


  [[[  1.30669668e-03   9.99955595e-01  -9.33431741e-03]
    [ -3.17609310e-03   9.33842827e-03   9.99951363e-01]
    [  9.99994099e-01  -1.27698644e-03   3.18815466e-03]]

   [[ -1.43117504e-03  -9.99949276e-01   9.96712316e-03]
    [  3.46249249e-03  -9.97202937e-03  -9.99944270e-01]
    [ -9.99992967e-01   1.39658421e-03  -3.47658852e-03]]

   [[ -1.48819678e-03  -9.99892950e-01   1.45547194e-02]
    [  3.74420546e-03  -1.45602049e-02  -9.99886990e-01]
    [ -9.99991894e-01   1.43353280e-03  -3.76547314e-03]]

   [[  1.45457999e-03   1.93449836e-02   9.99811828e-01]
    [ -3.94707546e-03   9.99805212e-01  -1.93391126e-02]
    [  9.99991179e-01   3.91820259e-03  -1.53065263e-03]]

   [[ -1.35325431e-03  -1.53862208e-03   9.99997914e-01]
    [  4.03842377e-03  -9.99990642e-01  -1.53314602e-03]
    [ -9.99990940e-01  -4.03634040e-03  -1.35945529e-03]]]


  ..., 
  [[[  1.52567867e-03   9.98370826e-01   5.70387878e-02]
    [  3.03875119e-03  -5.70432208e-02   9.98367071e-01]
    [  9.99994218e-01  -1.34986069e-03  -3.12083005e-03]]

   [[  1.59377279e-03   9.97604549e-01   6.91565350e-02]
    [  1.64615235e-03  -6.91591427e-02   9.97604311e-01]
    [  9.99997377e-01  -1.47611229e-03  -1.75243302e-03]]

   [[  1.56539411e-03   9.96367574e-01   8.51425231e-02]
    [ -8.32873775e-06  -8.51426125e-02   9.96368766e-01]
    [  9.99998748e-01  -1.56041898e-03  -1.24983271e-04]]

   [[  1.43688428e-03   9.94342327e-01   1.06213219e-01]
    [ -1.55005022e-03  -1.06210984e-01   9.94342387e-01]
    [  9.99997795e-01  -1.59339083e-03   1.38866773e-03]]

   [[  1.25465717e-03   9.91040409e-01   1.33556694e-01]
    [ -2.67813029e-03  -1.33552983e-01   9.91038084e-01]
    [  9.99995649e-01  -1.60109531e-03   2.48657214e-03]]]


  [[[  1.53153425e-03   9.98920202e-01   4.64339256e-02]
    [  4.13388945e-03  -4.64399084e-02   9.98912513e-01]
    [  9.99990284e-01  -1.33791601e-03  -4.20054980e-03]]

   [[  1.62588386e-03   9.98229682e-01   5.94547838e-02]
    [  2.79058004e-03  -5.94591573e-02   9.98226821e-01]
    [  9.99994755e-01  -1.45708758e-03  -2.88231345e-03]]

   [[  1.62186672e-03   9.97038722e-01   7.68839717e-02]
    [  1.16737932e-03  -7.68859088e-02   9.97039199e-01]
    [  9.99998033e-01  -1.52731198e-03  -1.28862110e-03]]

   [[  1.50906225e-03   9.94933367e-01   1.00525200e-01]
    [ -3.64472973e-04  -1.00524761e-01   9.94934499e-01]
    [  9.99998808e-01  -1.53805676e-03   2.10928207e-04]]

   [[  1.33177196e-03   9.91143465e-01   1.32788762e-01]
    [ -1.49834785e-03  -1.32786751e-01   9.91143525e-01]
    [  9.99997973e-01  -1.51894090e-03   1.30823604e-03]]]


  [[[  1.55934226e-03   9.98461545e-01   5.54262698e-02]
    [  5.39087411e-03  -5.54339252e-02   9.98447776e-01]
    [  9.99984264e-01  -1.25812576e-03  -5.46902092e-03]]

   [[  1.68392505e-03   9.97100294e-01   7.60799348e-02]
    [  4.01863735e-03  -7.60861784e-02   9.97093141e-01]
    [  9.99990523e-01  -1.37329253e-03  -4.13510762e-03]]

   [[  1.70854153e-03   9.94802535e-01   1.01808511e-01]
    [  2.32128659e-03  -1.01812325e-01   9.94800925e-01]
    [  9.99995828e-01  -1.46333198e-03  -2.48317258e-03]]

   [[  1.61493430e-03   9.90858674e-01   1.34894505e-01]
    [  6.90580870e-04  -1.34895757e-01   9.90859568e-01]
    [  9.99998450e-01  -1.50701753e-03  -9.02115775e-04]]

   [[  1.44471857e-03   9.83900905e-01   1.78708971e-01]
    [ -5.36883774e-04  -1.78708360e-01   9.83901918e-01]
    [  9.99998808e-01  -1.51740736e-03   2.70057120e-04]]]]



 [[[[  1.26594922e-03   9.98048306e-01   6.24338724e-02]
    [ -1.25552993e-03  -6.24322891e-02   9.98048425e-01]
    [  9.99998391e-01  -1.34186621e-03   1.17404340e-03]]

   [[  1.39097532e-03   8.74913812e-01   4.84276682e-01]
    [ -1.81916193e-03  -4.84274149e-01   8.74914408e-01]
    [  9.99997377e-01  -2.09796196e-03   9.17996455e-04]]

   [[  1.45405496e-03  -9.47707742e-02   9.95498061e-01]
    [ -2.51618563e-03   9.95495617e-01   9.47742164e-02]
    [  9.99995768e-01   2.64266483e-03  -1.20904448e-03]]

   [[  1.43001124e-03  -5.10758087e-02   9.98693764e-01]
    [ -3.17373290e-03   9.98689532e-01   5.10801338e-02]
    [  9.99993920e-01   3.24263237e-03  -1.26603618e-03]]

   [[  1.33809750e-03  -3.76113802e-02   9.99291539e-01]
    [ -3.64503916e-03   9.99285638e-01   3.76160368e-02]
    [  9.99992490e-01   3.69279063e-03  -1.20004662e-03]]]


  [[[  1.25717488e-03   9.99610305e-01   2.78858747e-02]
    [ -2.46585486e-03  -2.78827138e-02   9.99608159e-01]
    [  9.99996185e-01  -1.32544478e-03   2.42984062e-03]]

   [[  1.36777177e-03   9.93607879e-01   1.12878092e-01]
    [ -2.82263360e-03  -1.12873912e-01   9.93605316e-01]
    [  9.99995053e-01  -1.67763873e-03   2.65020528e-03]]

   [[  1.41533092e-03  -1.07608438e-01   9.94192362e-01]
    [ -3.22059449e-03   9.94187713e-01   1.07612520e-01]
    [  9.99993801e-01   3.35419760e-03  -1.06054137e-03]]

   [[  1.37879641e-03  -4.53656912e-02   9.98969495e-01]
    [ -3.55420029e-03   9.98963892e-01   4.53703441e-02]
    [  9.99992728e-01   3.61309433e-03  -1.21612905e-03]]

   [[  1.27981929e-03  -3.13678719e-02   9.99507070e-01]
    [ -3.75327398e-03   9.99500692e-01   3.13724764e-02]
    [  9.99992132e-01   3.79157509e-03  -1.16144808e-03]]]


  [[[  1.31418323e-03   9.99994934e-01  -2.90055806e-03]
    [ -4.00777720e-03   2.90580420e-03   9.99987721e-01]
    [  9.99991119e-01  -1.30254228e-03   4.01157606e-03]]

   [[ -1.42355508e-03   9.99911189e-01   1.32497018e-02]
    [  4.08617500e-03  -1.32437889e-02   9.99903977e-01]
    [ -9.99990642e-01  -1.47755886e-03   4.06695856e-03]]

   [[  1.46421301e-03  -1.58143282e-01   9.87415075e-01]
    [ -4.09220485e-03   9.87406909e-01   1.58148050e-01]
    [  9.99990582e-01   4.27226722e-03  -7.98619294e-04]]

   [[  1.41659169e-03  -3.22694369e-02   9.99478221e-01]
    [ -4.00830107e-03   9.99471009e-01   3.22748870e-02]
    [  9.99990940e-01   4.05192981e-03  -1.28649664e-03]]

   [[  1.30584522e-03  -2.18366012e-02   9.99760687e-01]
    [ -3.86119075e-03   9.99754012e-01   2.18414981e-02]
    [  9.99991715e-01   3.88878840e-03  -1.22120860e-03]]]


  ..., 
  [[[  1.47261471e-03   9.97720778e-01   6.74619973e-02]
    [  3.22696893e-03  -6.74664602e-02   9.97716308e-01]
    [  9.99993682e-01  -1.25155388e-03  -3.31896613e-03]]

   [[  1.52430369e-03   9.97270823e-01   7.38142952e-02]
    [  1.87769276e-03  -7.38171041e-02   9.97270048e-01]
    [  9.99997079e-01  -1.38154184e-03  -1.98508799e-03]]

   [[  1.48355367e-03   9.96926606e-01   7.83274323e-02]
    [  2.94101628e-04  -7.83279538e-02   9.96927619e-01]
    [  9.99998868e-01  -1.45595940e-03  -4.09401429e-04]]

   [[  1.35090249e-03   9.96813297e-01   7.97588378e-02]
    [ -1.16811902e-03  -7.97572806e-02   9.96813655e-01]
    [  9.99998391e-01  -1.43976579e-03   1.05665228e-03]]

   [[  1.17258914e-03   9.96993721e-01   7.74736777e-02]
    [ -2.23164889e-03  -7.74709284e-02   9.96992111e-01]
    [  9.99996841e-01  -1.34195620e-03   2.13409821e-03]]]


  [[[  1.46458065e-03   9.98968363e-01   4.53878827e-02]
    [  5.73174190e-03  -4.53955717e-02   9.98952627e-01]
    [  9.99982476e-01  -1.20289507e-03  -5.79231465e-03]]

   [[  1.53208512e-03   9.98586178e-01   5.31352609e-02]
    [  4.21839021e-03  -5.31413034e-02   9.98578072e-01]
    [  9.99989927e-01  -1.30576140e-03  -4.29384317e-03]]

   [[  1.50788506e-03   9.98162031e-01   6.05831444e-02]
    [  2.38459487e-03  -6.05866276e-02   9.98160124e-01]
    [  9.99996006e-01  -1.36064447e-03  -2.47156969e-03]]

   [[  1.38794642e-03   9.97767687e-01   6.67658970e-02]
    [  6.45394204e-04  -6.67668432e-02   9.97768402e-01]
    [  9.99998808e-01  -1.34175876e-03  -7.36622314e-04]]

   [[  1.21608737e-03   9.97502267e-01   7.06238300e-02]
    [ -6.54198055e-04  -7.06230700e-02   9.97502863e-01]
    [  9.99999046e-01  -1.25925255e-03   5.66680217e-04]]]


  [[[ -1.47129025e-03   9.99537408e-01   3.03784348e-02]
    [ -7.60722300e-03  -3.03887762e-02   9.99509215e-01]
    [ -9.99969959e-01  -1.23947265e-03  -7.64841447e-03]]

   [[  1.56201352e-03   9.99087453e-01   4.26830389e-02]
    [  5.95349586e-03  -4.26916257e-02   9.99070585e-01]
    [  9.99981046e-01  -1.30644848e-03  -6.01474755e-03]]

   [[  1.56181690e-03   9.98477221e-01   5.51437996e-02]
    [  3.89637053e-03  -5.51495217e-02   9.98470485e-01]
    [  9.99991179e-01  -1.34456740e-03  -3.97657091e-03]]

   [[  1.46026211e-03   9.97689486e-01   6.79235682e-02]
    [  1.90618588e-03  -6.79262951e-02   9.97688532e-01]
    [  9.99997139e-01  -1.32741174e-03  -2.00097170e-03]]

   [[  1.29793258e-03   9.96665061e-01   8.15907493e-02]
    [  3.92076588e-04  -8.15913230e-02   9.96665776e-01]
    [  9.99999106e-01  -1.26161519e-03  -4.96669032e-04]]]]



 [[[[ -1.31193222e-03   9.99619246e-01   2.75616087e-02]
    [  1.47599634e-03  -2.75596678e-02   9.99619067e-01]
    [ -9.99998033e-01  -1.35211332e-03   1.43927790e-03]]

   [[  1.43071334e-03  -7.68690407e-02   9.97040153e-01]
    [ -1.89819548e-03   9.97039199e-01   7.68716931e-02]
    [  9.99997199e-01   2.00255844e-03  -1.28056481e-03]]

   [[  1.48187776e-03  -3.03536244e-02   9.99538124e-01]
    [ -2.40985258e-03   9.99536216e-01   3.03571392e-02]
    [  9.99996006e-01   2.45372509e-03  -1.40804274e-03]]

   [[  1.44270493e-03  -2.24942807e-02   9.99745905e-01]
    [ -2.88126175e-03   9.99742746e-01   2.24983655e-02]
    [  9.99994814e-01   2.91298819e-03  -1.37752178e-03]]

   [[  1.33643474e-03  -1.91229060e-02   9.99816239e-01]
    [ -3.20709590e-03   9.99811888e-01   1.91271100e-02]
    [  9.99993980e-01   3.23206862e-03  -1.27485429e-03]]]


  [[[ -1.29572023e-03   9.99905169e-01   1.37112923e-02]
    [  3.18572274e-03  -1.37071069e-02   9.99900997e-01]
    [ -9.99994099e-01  -1.33927236e-03   3.16765998e-03]]

   [[  1.40456145e-03  -3.77245069e-01   9.26112413e-01]
    [ -3.38398642e-03   9.26106215e-01   3.77247691e-01]
    [  9.99993265e-01   3.66381928e-03  -2.41808521e-05]]

   [[  1.44546852e-03  -3.88298854e-02   9.99244809e-01]
    [ -3.57053545e-03   9.99239266e-01   3.88348363e-02]
    [  9.99992609e-01   3.62397335e-03  -1.30572543e-03]]

   [[  1.39825256e-03  -2.54678391e-02   9.99674678e-01]
    [ -3.68516054e-03   9.99668717e-01   2.54728422e-02]
    [  9.99992251e-01   3.71957920e-03  -1.30393624e-03]]

   [[  1.28745520e-03  -2.03618035e-02   9.99791861e-01]
    [ -3.70481471e-03   9.99785721e-01   2.03664508e-02]
    [  9.99992311e-01   3.73026449e-03  -1.21174264e-03]]]


  [[[ -1.32797228e-03  -9.99975443e-01   6.88446313e-03]
    [  4.79238341e-03  -6.89075422e-03  -9.99964774e-01]
    [ -9.99987662e-01   1.29493244e-03  -4.80141630e-03]]

   [[ -1.43363979e-03   9.99305725e-01   3.72288115e-02]
    [  4.76079201e-03  -3.72216068e-02   9.99295712e-01]
    [ -9.99987662e-01  -1.60986860e-03   4.70412429e-03]]

   [[  1.46787346e-03  -5.23861349e-02   9.98625815e-01]
    [ -4.61775344e-03   9.98615921e-01   5.23924045e-02]
    [  9.99988258e-01   4.68831323e-03  -1.22393563e-03]]

   [[  1.41198491e-03  -2.99469270e-02   9.99550521e-01]
    [ -4.37460002e-03   9.99541759e-01   2.99528446e-02]
    [  9.99989450e-01   4.41492675e-03  -1.28033198e-03]]

   [[  1.29290868e-03  -2.33746152e-02   9.99725938e-01]
    [ -4.09063790e-03   9.99718308e-01   2.33797263e-02]
    [  9.99990821e-01   4.11974499e-03  -1.19692739e-03]]]


  ..., 
  [[[  1.54077495e-03   9.95140433e-01   9.84536111e-02]
    [  3.44246277e-03  -9.84584242e-02   9.95135188e-01]
    [  9.99992907e-01  -1.19435648e-03  -3.57743632e-03]]

   [[  1.56805629e-03   9.95740235e-01   9.21898708e-02]
    [  2.26696930e-03  -9.21932831e-02   9.95738566e-01]
    [  9.99996185e-01  -1.35238247e-03  -2.40187673e-03]]

   [[  1.49804808e-03   9.96714532e-01   8.09808224e-02]
    [  9.11088719e-04  -8.09822455e-02   9.96715128e-01]
    [  9.99998450e-01  -1.41934643e-03  -1.02941063e-03]]

   [[  1.33915129e-03   9.97770071e-01   6.67311773e-02]
    [ -3.26684938e-04  -6.67307973e-02   9.97770965e-01]
    [  9.99999046e-01  -1.35796634e-03   2.36593827e-04]]

   [[  1.14344398e-03   9.98652339e-01   5.18863574e-02]
    [ -1.22282060e-03  -5.18849567e-02   9.98652339e-01]
    [  9.99998569e-01  -1.20535062e-03   1.16184505e-03]]]


  [[[  1.51037867e-03   9.98206675e-01   5.98429218e-02]
    [  7.16346502e-03  -5.98522536e-02   9.98181522e-01]
    [  9.99973178e-01  -1.07894943e-03  -7.24101812e-03]]

   [[  1.54516485e-03   9.98361409e-01   5.72028421e-02]
    [  5.61521901e-03  -5.72106689e-02   9.98346329e-01]
    [  9.99983013e-01  -1.22140313e-03  -5.69441775e-03]]

   [[  1.48666953e-03   9.98734355e-01   5.02745770e-02]
    [  3.73875536e-03  -5.02798334e-02   9.98728156e-01]
    [  9.99991894e-01  -1.29681441e-03  -3.80877289e-03]]

   [[  1.34026236e-03   9.99201834e-01   3.99233401e-02]
    [  1.95270311e-03  -3.99259143e-02   9.99200761e-01]
    [  9.99997199e-01  -1.26123277e-03  -2.00465578e-03]]

   [[  1.15462008e-03   9.99613345e-01   2.77825128e-02]
    [  6.05817419e-04  -2.77832262e-02   9.99613762e-01]
    [  9.99999166e-01  -1.13734300e-03  -6.37662190e-04]]]


  [[[ -1.48166588e-03  -9.99995053e-01   2.77267117e-03]
    [ -9.46295541e-03  -2.75852927e-03  -9.99951422e-01]
    [ -9.99954104e-01   1.50783162e-03   9.45882127e-03]]

   [[ -1.53441960e-03  -9.99996841e-01   1.97948981e-03]
    [ -7.66597548e-03  -1.96767133e-03  -9.99968708e-01]
    [ -9.99969423e-01   1.54954626e-03   7.66293239e-03]]

   [[ -1.49811560e-03  -9.99969125e-01   7.71687552e-03]
    [ -5.42529160e-03  -7.70864310e-03  -9.99955595e-01]
    [ -9.99984145e-01   1.53991533e-03   5.41357556e-03]]

   [[ -1.37245830e-03  -9.99816716e-01   1.90964658e-02]
    [ -3.24792624e-03  -1.90919265e-02  -9.99812484e-01]
    [ -9.99993801e-01   1.43422477e-03   3.22112790e-03]]

   [[ -1.20154093e-03  -9.99372661e-01   3.53946723e-02]
    [ -1.57764170e-03  -3.53927575e-02  -9.99372244e-01]
    [ -9.99998033e-01   1.25662680e-03   1.53412623e-03]]]]



 ..., 
 [[[[  2.05950206e-03   9.89581048e-01   1.43962249e-01]
    [ -6.43584572e-05  -1.43962428e-01   9.89583135e-01]
    [  9.99997854e-01  -2.04731384e-03  -2.32803010e-04]]

   [[  2.22087139e-03   9.88973975e-01   1.48072958e-01]
    [ -3.34826531e-04  -1.48072585e-01   9.88976419e-01]
    [  9.99997497e-01  -2.24596821e-03   2.28456224e-06]]

   [[  2.25480623e-03   9.86767411e-01   1.62126452e-01]
    [ -5.98622893e-04  -1.62125498e-01   9.86769974e-01]
    [  9.99997258e-01  -2.32202769e-03   2.25139942e-04]]

   [[  2.13793968e-03   9.81295586e-01   1.92495108e-01]
    [ -7.94122694e-04  -1.92493826e-01   9.81297851e-01]
    [  9.99997377e-01  -2.25082040e-03   3.67728935e-04]]

   [[  1.92295364e-03   9.66503143e-01   2.56647587e-01]
    [ -8.95549485e-04  -2.56646305e-01   9.66504991e-01]
    [  9.99997735e-01  -2.08838494e-03   3.72032460e-04]]]


  [[[  2.04167422e-03  -2.58803457e-01   9.65927839e-01]
    [ -2.31194499e-04   9.65929687e-01   2.58804470e-01]
    [  9.99997914e-01   7.51711545e-04  -1.91227975e-03]]

   [[  2.18992028e-03  -4.64533538e-01   8.85552824e-01]
    [ -8.02076480e-04   8.85553837e-01   4.64536041e-01]
    [  9.99997258e-01   1.72757800e-03  -1.56670087e-03]]

   [[  2.20664078e-03  -6.39940083e-01   7.68421650e-01]
    [ -1.43408822e-03   7.68420696e-01   6.39943361e-01]
    [  9.99996543e-01   2.51410971e-03  -7.77898007e-04]]

   [[  2.07279180e-03  -6.59334600e-01   7.51846790e-01]
    [ -1.98471756e-03   7.51844168e-01   6.59337819e-01]
    [  9.99995887e-01   2.85887369e-03  -2.49823439e-04]]

   [[  1.84500066e-03  -5.46206117e-01   8.37648749e-01]
    [ -2.35796277e-03   8.37645471e-01   5.46209157e-01]
    [  9.99995530e-01   2.98290094e-03  -2.57522799e-04]]]


  [[[  1.93706458e-03  -5.69386557e-02   9.98375773e-01]
    [  8.33446451e-04   9.98377442e-01   5.69371283e-02]
    [  9.99997795e-01  -7.21801887e-04  -1.98137690e-03]]

   [[  2.08257604e-03  -9.58339125e-02   9.95395184e-01]
    [  2.05686524e-06   9.95397329e-01   9.58341137e-02]
    [  9.99997854e-01   1.97534435e-04  -2.07318761e-03]]

   [[  2.09956709e-03  -1.57156631e-01   9.87571478e-01]
    [ -9.79138422e-04   9.87572849e-01   1.57158926e-01]
    [  9.99997318e-01   1.29693490e-03  -1.91959739e-03]]

   [[  1.96929392e-03  -2.30092913e-01   9.73166704e-01]
    [ -1.89021497e-03   9.73165989e-01   2.30096564e-01]
    [  9.99996245e-01   2.29262211e-03  -1.48152479e-03]]

   [[  1.74705149e-03  -2.73266375e-01   9.61936831e-01]
    [ -2.55704159e-03   9.61933911e-01   2.73270190e-01]
    [  9.99995232e-01   2.93712947e-03  -9.81794554e-04]]]


  ..., 
  [[[  1.77648920e-03   1.29293531e-01   9.91604745e-01]
    [ -2.18110843e-04   9.91606355e-01  -1.29293337e-01]
    [  9.99998391e-01  -1.34084867e-05  -1.78977835e-03]]

   [[  1.89910282e-03  -1.72364786e-01   9.85031366e-01]
    [  6.22761610e-04   9.85033154e-01   1.72363892e-01]
    [  9.99997973e-01  -2.86102964e-04  -1.97802135e-03]]

   [[  1.91370095e-03  -1.80757448e-01   9.83525872e-01]
    [  1.65347836e-03   9.83526886e-01   1.80754423e-01]
    [  9.99996781e-01  -1.28032884e-03  -2.18105479e-03]]

   [[  1.80538115e-03  -1.57250211e-01   9.87557173e-01]
    [  2.65917834e-03   9.87556040e-01   1.57245174e-01]
    [  9.99994814e-01  -2.34220317e-03  -2.20107147e-03]]

   [[  1.62112503e-03  -1.34765342e-01   9.90876198e-01]
    [  3.44792334e-03   9.90872383e-01   1.34759188e-01]
    [  9.99992728e-01  -3.19800386e-03  -2.07098853e-03]]]


  [[[  1.71554659e-03  -5.20809600e-03   9.99984980e-01]
    [  2.46085599e-03   9.99983430e-01   5.20386593e-03]
    [  9.99995530e-01  -2.45189155e-03  -1.72833446e-03]]

   [[  1.84813363e-03  -3.91599871e-02   9.99231219e-01]
    [  3.35658155e-03   9.99227583e-01   3.91536355e-02]
    [  9.99992669e-01  -3.28164012e-03  -1.97814964e-03]]

   [[  1.87882991e-03  -8.70141685e-02   9.96205330e-01]
    [  4.43297811e-03   9.96197999e-01   8.70051682e-02]
    [  9.99988437e-01  -4.25268849e-03  -2.25741859e-03]]

   [[  1.78877846e-03  -1.31379321e-01   9.91330564e-01]
    [  5.45503199e-03   9.91318703e-01   1.31367907e-01]
    [  9.99983549e-01  -5.17275184e-03  -2.48992792e-03]]

   [[  1.62002142e-03  -1.53666362e-01   9.88121450e-01]
    [  6.22707559e-03   9.88105178e-01   1.53653622e-01]
    [  9.99979317e-01  -5.90418512e-03  -2.55764346e-03]]]


  [[[  1.69697637e-03  -8.85467697e-03   9.99959350e-01]
    [  4.35462082e-03   9.99951363e-01   8.84721708e-03]
    [  9.99989092e-01  -4.33943048e-03  -1.73545268e-03]]

   [[  1.83175900e-03  -2.27846820e-02   9.99738693e-01]
    [  4.99112066e-03   9.99728143e-01   2.27752961e-02]
    [  9.99985874e-01  -4.94809775e-03  -1.94498210e-03]]

   [[  1.86735054e-03  -4.62143160e-02   9.98929799e-01]
    [  5.73595893e-03   9.98915613e-01   4.62029390e-02]
    [  9.99981821e-01  -5.64354332e-03  -2.13040900e-03]]

   [[  1.78342743e-03  -8.08096379e-02   9.96727943e-01]
    [  6.41513569e-03   9.96709943e-01   8.07967037e-02]
    [  9.99977827e-01  -6.25004992e-03  -2.29596463e-03]]

   [[  1.61990197e-03  -1.20825715e-01   9.92672443e-01]
    [  6.89694379e-03   9.92651463e-01   1.20811909e-01]
    [  9.99974906e-01  -6.65070256e-03  -2.44132616e-03]]]]



 [[[[  1.84624922e-03   9.67879772e-01   2.51406759e-01]
    [  2.56769801e-03  -2.51410931e-01   9.67877030e-01]
    [  9.99994993e-01  -1.14140555e-03  -2.94939033e-03]]

   [[  2.00815569e-03   9.88565028e-01   1.50781840e-01]
    [  1.95937976e-03  -1.50785744e-01   9.88564551e-01]
    [  9.99996066e-01  -1.68975268e-03  -2.23977538e-03]]

   [[  2.05299724e-03   9.94685233e-01   1.02942355e-01]
    [  1.23457657e-03  -1.02945015e-01   9.94686306e-01]
    [  9.99997139e-01  -1.91499805e-03  -1.43936090e-03]]

   [[  1.95540837e-03   9.97144580e-01   7.54906312e-02]
    [  5.53989958e-04  -7.54918456e-02   9.97146249e-01]
    [  9.99997914e-01  -1.90800719e-03  -7.00025470e-04]]

   [[  1.76220224e-03   9.98324215e-01   5.78419417e-02]
    [  4.87983489e-05  -5.78421168e-02   9.98325765e-01]
    [  9.99998450e-01  -1.75642932e-03  -1.50646083e-04]]]


  [[[  1.85413880e-03  -3.82229418e-01   9.24065590e-01]
    [  2.26621400e-03   9.24066424e-01   3.82225215e-01]
    [  9.99995708e-01  -1.38543174e-03  -2.57956097e-03]]

   [[  2.00648815e-03   9.14780974e-01   4.03945267e-01]
    [  1.37290813e-03  -4.03948218e-01   9.14780855e-01]
    [  9.99997020e-01  -1.28091720e-03  -2.06642761e-03]]

   [[  2.03716173e-03   9.85284984e-01   1.70907363e-01]
    [  3.08688992e-04  -1.70908332e-01   9.85286891e-01]
    [  9.99997854e-01  -1.95443165e-03  -6.52314571e-04]]

   [[  1.92422979e-03   9.94449735e-01   1.05194904e-01]
    [ -6.89586799e-04  -1.05193757e-01   9.94451523e-01]
    [  9.99997914e-01  -1.98609428e-03   4.83342446e-04]]

   [[  1.71837281e-03   9.97145414e-01   7.54852667e-02]
    [ -1.42981170e-03  -7.54828528e-02   9.97146070e-01]
    [  9.99997497e-01  -1.82139839e-03   1.29602244e-03]]]


  [[[  1.78587262e-03  -1.17666915e-01   9.93051529e-01]
    [  2.30611884e-03   9.93050933e-01   1.17662698e-01]
    [  9.99995768e-01  -2.07996415e-03  -2.04481627e-03]]

   [[  1.93709158e-03  -3.05656850e-01   9.52139795e-01]
    [  1.20028551e-03   9.52141583e-01   3.05655003e-01]
    [  9.99997377e-01  -5.50757919e-04  -2.21126084e-03]]

   [[  1.96800637e-03   9.28825021e-01   3.70513439e-01]
    [ -1.31558889e-04  -3.70513916e-01   9.28826928e-01]
    [  9.99998033e-01  -1.87668169e-03  -6.06978603e-04]]

   [[  1.85691379e-03   9.88903046e-01   1.48550734e-01]
    [ -1.39031024e-03  -1.48548290e-01   9.88904178e-01]
    [  9.99997318e-01  -2.04284140e-03   1.09904062e-03]]

   [[  1.65394845e-03   9.95572209e-01   9.39855054e-02]
    [ -2.32938351e-03  -9.39815417e-02   9.95571196e-01]
    [  9.99995947e-01  -1.86555181e-03   2.16362881e-03]]]


  ..., 
  [[[  1.95984542e-03  -4.37618762e-01   8.99158478e-01]
    [  2.19282834e-03   8.99159908e-01   4.37614709e-01]
    [  9.99995649e-01  -1.11404294e-03  -2.72183726e-03]]

   [[  2.12094886e-03  -3.26880127e-01   9.45063412e-01]
    [  2.27200706e-03   9.45064723e-01   3.26875448e-01]
    [  9.99995172e-01  -1.45390467e-03  -2.74710776e-03]]

   [[  2.15691398e-03  -2.48042181e-01   9.68746841e-01]
    [  2.32335925e-03   9.68747735e-01   2.48037234e-01]
    [  9.99994993e-01  -1.71575183e-03  -2.66579655e-03]]

   [[  2.04483257e-03  -1.96052238e-01   9.80591297e-01]
    [  2.35241838e-03   9.80591595e-01   1.96047395e-01]
    [  9.99995172e-01  -1.90587679e-03  -2.46634264e-03]]

   [[  1.83680258e-03  -1.60904184e-01   9.86968338e-01]
    [  2.37552729e-03   9.86967921e-01   1.60899699e-01]
    [  9.99995470e-01  -2.04902911e-03  -2.19509751e-03]]]


  [[[  1.99589459e-03  -7.36267418e-02   9.97283876e-01]
    [  4.86218277e-03   9.97274756e-01   7.36163408e-02]
    [  9.99986172e-01  -4.70204605e-03  -2.34844210e-03]]

   [[  2.16948125e-03  -1.41154855e-01   9.89985168e-01]
    [  5.05630765e-03   9.89976346e-01   1.41142517e-01]
    [  9.99984860e-01  -4.69946349e-03  -2.86145741e-03]]

   [[  2.21593538e-03  -2.28049368e-01   9.73647058e-01]
    [  5.22807427e-03   9.73638773e-01   2.28035539e-01]
    [  9.99983907e-01  -4.58498672e-03  -3.34977964e-03]]

   [[  2.10889336e-03  -3.01139772e-01   9.53577697e-01]
    [  5.34479599e-03   9.53569591e-01   3.01125377e-01]
    [  9.99983490e-01  -4.46163723e-03  -3.62050720e-03]]

   [[  1.89979724e-03  -3.32591444e-01   9.43069100e-01]
    [  5.40243881e-03   9.43060458e-01   3.32577527e-01]
    [  9.99983609e-01  -4.46304353e-03  -3.58842872e-03]]]


  [[[  2.05175835e-03  -4.89438586e-02   9.98799443e-01]
    [  5.97117841e-03   9.98784304e-01   4.89308536e-02]
    [  9.99980092e-01  -5.86361531e-03  -2.34151655e-03]]

   [[  2.22707656e-03  -9.41821560e-02   9.95552480e-01]
    [  6.14807475e-03   9.95537460e-01   9.41669792e-02]
    [  9.99978602e-01  -5.91101404e-03  -2.79617705e-03]]

   [[  2.27228180e-03  -1.97676539e-01   9.80264664e-01]
    [  6.29279669e-03   9.80250597e-01   1.97659120e-01]
    [  9.99977648e-01  -5.71946893e-03  -3.47134378e-03]]

   [[  2.16048304e-03  -4.69576180e-01   8.82889330e-01]
    [  6.36464637e-03   8.82879972e-01   4.69555616e-01]
    [  9.99977410e-01  -4.60481131e-03  -4.89613367e-03]]

   [[  1.94427907e-03  -8.20936143e-01  -5.71016669e-01]
    [  6.36076834e-03   5.71016371e-01  -8.20914030e-01]
    [  9.99977887e-01  -2.03601876e-03   6.33199979e-03]]]]



 [[[[  1.71475101e-03   9.66982186e-01   2.54838169e-01]
    [  4.38826671e-03  -2.54843384e-01   9.66972411e-01]
    [  9.99988914e-01  -5.39819070e-04  -4.68036858e-03]]

   [[  1.86118239e-03   9.90474820e-01   1.37681291e-01]
    [  3.56395775e-03  -1.37687221e-01   9.90469337e-01]
    [  9.99991894e-01  -1.35275384e-03  -3.78627144e-03]]

   [[  1.89615705e-03   9.96266186e-01   8.63136426e-02]
    [  2.53199181e-03  -8.63183066e-02   9.96264398e-01]
    [  9.99994993e-01  -1.67052820e-03  -2.68621091e-03]]

   [[  1.79772160e-03   9.98274982e-01   5.86841181e-02]
    [  1.52087177e-03  -5.86868748e-02   9.98275280e-01]
    [  9.99997199e-01  -1.70537003e-03  -1.62375090e-03]]

   [[  1.61157537e-03   9.99115884e-01   4.20100354e-02]
    [  7.36502523e-04  -4.20112647e-02   9.99116838e-01]
    [  9.99998450e-01  -1.57921168e-03  -8.03555653e-04]]]


  [[[  1.74846349e-03   8.75681460e-01   4.82886016e-01]
    [  4.20330139e-03  -4.82888907e-01   8.75671506e-01]
    [  9.99989629e-01   4.98635811e-04  -4.52506682e-03]]

   [[  1.88761461e-03   9.80870664e-01   1.94651335e-01]
    [  3.15788249e-03  -1.94656566e-01   9.80866373e-01]
    [  9.99993205e-01  -1.23681163e-03  -3.46491090e-03]]

   [[  1.91029557e-03   9.94107783e-01   1.08379334e-01]
    [  1.86791702e-03  -1.08382896e-01   9.94107485e-01]
    [  9.99996424e-01  -1.69659546e-03  -2.06395425e-03]]

   [[  1.79739972e-03   9.97509122e-01   7.05146492e-02]
    [  6.20013918e-04  -7.05158561e-02   9.97510493e-01]
    [  9.99998212e-01  -1.74920494e-03  -7.45214755e-04]]

   [[  1.59844523e-03   9.98755157e-01   4.98558730e-02]
    [ -3.35983437e-04  -4.98553962e-02   9.98756409e-01]
    [  9.99998689e-01  -1.61320809e-03   2.55874067e-04]]]


  [[[  1.70804025e-03  -4.73342955e-01   8.80876601e-01]
    [  3.62769607e-03   8.80874991e-01   4.73335057e-01]
    [  9.99991953e-01  -2.38707708e-03  -3.22171417e-03]]

   [[  1.84813992e-03   9.48989093e-01   3.15303475e-01]
    [  2.44942866e-03  -3.15307379e-01   9.48986411e-01]
    [  9.99995291e-01  -9.81546240e-04  -2.90721329e-03]]

   [[  1.87241507e-03   9.90613163e-01   1.36682153e-01]
    [  1.00456376e-03  -1.36684179e-01   9.90614176e-01]
    [  9.99997735e-01  -1.71753496e-03  -1.25106366e-03]]

   [[  1.76151888e-03   9.96636033e-01   8.19361955e-02]
    [ -3.82399885e-04  -8.19356441e-02   9.96637523e-01]
    [  9.99998391e-01  -1.78692827e-03   2.36782318e-04]]

   [[  1.56459259e-03   9.98408318e-01   5.63774444e-02]
    [ -1.43428531e-03  -5.63752130e-02   9.98408616e-01]
    [  9.99997735e-01  -1.64296408e-03   1.34379813e-03]]]


  ..., 
  [[[  2.26605381e-03  -8.21931124e-01  -5.69582343e-01]
    [  4.51856805e-03   5.69586396e-01  -8.21919024e-01]
    [  9.99987245e-01  -7.11183820e-04   5.00466535e-03]]

   [[  2.46287836e-03  -4.44539487e-01   8.95755887e-01]
    [  3.67412483e-03   8.95756543e-01   4.44529712e-01]
    [  9.99990225e-01  -2.19629635e-03  -3.83943296e-03]]

   [[  2.50451593e-03  -2.67349213e-01   9.63596463e-01]
    [  2.54580588e-03   9.63598073e-01   2.67343044e-01]
    [  9.99993622e-01  -1.78356445e-03  -3.09396582e-03]]

   [[  2.36273324e-03  -1.91368878e-01   9.81515348e-01]
    [  1.40717102e-03   9.81517732e-01   1.91365972e-01]
    [  9.99996245e-01  -9.29013186e-04  -2.58835335e-03]]

   [[  2.10246979e-03  -1.50078326e-01   9.88671899e-01]
    [  5.23998518e-04   9.88674104e-01   1.50077537e-01]
    [  9.99997675e-01  -2.02529103e-04  -2.15729815e-03]]]


  [[[  2.39077467e-03  -1.82164147e-01   9.83265221e-01]
    [  7.03689735e-03   9.83246744e-01   1.82143614e-01]
    [  9.99972403e-01  -6.48367172e-03  -3.63259180e-03]]

   [[  2.60464498e-03  -2.63234466e-01   9.64728355e-01]
    [  6.34357193e-03   9.64716554e-01   2.63214141e-01]
    [  9.99976516e-01  -5.43424441e-03  -4.18259110e-03]]

   [[  2.65417527e-03  -3.20567846e-01   9.47221816e-01]
    [  5.38460212e-03   9.47216034e-01   3.20550799e-01]
    [  9.99981999e-01  -4.24961466e-03  -4.24020737e-03]]

   [[  2.50734738e-03  -3.36293876e-01   9.41753745e-01]
    [  4.38366737e-03   9.41751361e-01   3.36281359e-01]
    [  9.99987245e-01  -3.28516099e-03  -3.83549812e-03]]

   [[  2.23189918e-03  -3.19571286e-01   9.47559595e-01]
    [  3.57352104e-03   9.47558463e-01   3.19562495e-01]
    [  9.99991119e-01  -2.67289276e-03  -3.25684948e-03]]]


  [[[  2.50513060e-03  -1.12470053e-01   9.93651986e-01]
    [  7.26889679e-03   9.93630886e-01   1.12449341e-01]
    [  9.99970436e-01  -6.94105309e-03  -3.30670830e-03]]

   [[  2.72277440e-03  -2.02674836e-01   9.79242325e-01]
    [  6.85032690e-03   9.79226768e-01   2.02652559e-01]
    [  9.99972820e-01  -6.15635235e-03  -4.05460224e-03]]

   [[  2.76895077e-03  -3.85497570e-01   9.22704697e-01]
    [  6.23374013e-03   9.22696948e-01   3.85475636e-01]
    [  9.99976754e-01  -4.68453811e-03  -4.95799398e-03]]

   [[  2.61110486e-03  -6.60043120e-01   7.51223147e-01]
    [  5.55131724e-03   7.51223743e-01   6.60024285e-01]
    [  9.99981165e-01  -2.44688522e-03  -5.62563259e-03]]

   [[  2.32018367e-03  -8.35079253e-01  -5.50124764e-01]
    [  4.95995302e-03   5.50129116e-01  -8.35064888e-01]
    [  9.99984980e-01  -7.91089027e-04   5.41835465e-03]]]]]

In [47]:
cfa = RGB[:, :, :]

In [48]:
cfa = cfa / cfa.max()

In [49]:
print "printing cfa"
print cfa


printing cfa
[[[[  9.48516536e-04   6.63962739e-04   7.63682663e-01]
   [  1.05907558e-03   1.17917871e-03   7.68453181e-01]
   [  1.12608611e-03   1.83443225e-03   7.74188817e-01]
   [  1.12518156e-03   2.47214711e-03   7.79890180e-01]
   [  1.06707367e-03   2.94861686e-03   7.84818709e-01]]

  [[  9.09874274e-04   1.26029446e-03   7.37221777e-01]
   [  1.00808835e-03   1.67472509e-03   7.43754089e-01]
   [  1.06387143e-03   2.17684289e-03   7.51397967e-01]
   [  1.05572050e-03   2.64528813e-03   7.58563519e-01]
   [  9.95318987e-04   2.97875307e-03   7.64250219e-01]]

  [[  9.03575972e-04   2.19625677e-03   6.91492260e-01]
   [  1.00644864e-03   2.43493705e-03   7.03227460e-01]
   [  1.06497563e-03   2.67940876e-03   7.15609014e-01]
   [  1.05680479e-03   2.86769238e-03   7.26529598e-01]
   [  9.94428527e-04   2.96760467e-03   7.34835625e-01]]

  ..., 
  [[  1.27324078e-03   2.53596087e-03   8.34535718e-01]
   [  1.33825780e-03   1.38223974e-03   8.39676917e-01]
   [  1.31950260e-03   7.02046282e-06   8.42919350e-01]
   [  1.21273112e-03   1.30824326e-03   8.43998730e-01]
   [  1.05783681e-03   2.25800718e-03   8.43124509e-01]]

  [[  1.21419330e-03   3.27732856e-03   7.92787671e-01]
   [  1.30230980e-03   2.23521492e-03   8.00981581e-01]
   [  1.30918657e-03   9.42319923e-04   8.07208121e-01]
   [  1.22404587e-03   2.95634993e-04   8.11129153e-01]
   [  1.08255702e-03   1.21796154e-03   8.12867999e-01]]

  [[  1.19536358e-03   4.13254648e-03   7.66569912e-01]
   [  1.31279498e-03   3.13294632e-03   7.79596806e-01]
   [  1.34897733e-03   1.83276949e-03   7.89545715e-01]
   [  1.28541712e-03   5.49672171e-04   7.95955002e-01]
   [  1.15428725e-03   4.28954168e-04   7.98969269e-01]]]


 [[[  9.61241545e-04   9.53330135e-04   7.59303749e-01]
   [  1.06929545e-03   1.39845873e-03   7.68735826e-01]
   [  1.13186671e-03   1.95865147e-03   7.78417587e-01]
   [  1.12571975e-03   2.49839551e-03   7.87205637e-01]
   [  1.06299378e-03   2.89564393e-03   7.94400871e-01]]

  [[  9.35247052e-04   1.83441746e-03   7.43924737e-01]
   [  1.03580835e-03   2.13756948e-03   7.57292390e-01]
   [  1.08988385e-03   2.48003774e-03   7.70051122e-01]
   [  1.07637618e-03   2.77463463e-03   7.80657947e-01]
   [  1.00906112e-03   2.95923231e-03   7.88434088e-01]]

  [[  9.32199880e-04   2.84286775e-03   7.09331453e-01]
   [  1.03939744e-03   2.98348791e-03   7.30135143e-01]
   [  1.09680754e-03   3.06537445e-03   7.49069452e-01]
   [  1.08257169e-03   3.06317862e-03   7.64201760e-01]
   [  1.01189560e-03   2.99202534e-03   7.74890661e-01]]

  ..., 
  [[  1.24968763e-03   2.73846462e-03   8.48612845e-01]
   [  1.29627576e-03   1.59679959e-03   8.50402653e-01]
   [  1.25959283e-03   2.49703327e-04   8.49036634e-01]
   [  1.14027341e-03   9.85989114e-04   8.44081342e-01]
   [  9.79997916e-04   1.86511304e-03   8.35752964e-01]]

  [[  1.14887010e-03   4.49618604e-03   7.84422457e-01]
   [  1.20919454e-03   3.32935457e-03   7.89239705e-01]
   [  1.19281258e-03   1.88633404e-03   7.91046917e-01]
   [  1.09559833e-03   5.09452482e-04   7.89365411e-01]
   [  9.53915878e-04   5.13162056e-04   7.84413159e-01]]

  [[  1.07944664e-03   5.58121828e-03   7.33651459e-01]
   [  1.16150512e-03   4.42698831e-03   7.43580699e-01]
   [  1.17118552e-03   2.92183599e-03   7.49879956e-01]
   [  1.09804282e-03   1.43335469e-03   7.51946926e-01]
   [  9.73471848e-04   2.94064230e-04   7.50016630e-01]]]


 [[[  9.47365479e-04   1.06583862e-03   7.22113252e-01]
   [  1.05103594e-03   1.39445940e-03   7.34621584e-01]
   [  1.10717665e-03   1.80050777e-03   7.47141421e-01]
   [  1.09428680e-03   2.18542735e-03   7.58492708e-01]
   [  1.02631154e-03   2.46288092e-03   7.67942727e-01]]

  [[  9.40103258e-04   2.31138500e-03   7.25540638e-01]
   [  1.04288058e-03   2.51259445e-03   7.42490470e-01]
   [  1.09572115e-03   2.70660408e-03   7.58033097e-01]
   [  1.07778818e-03   2.84056156e-03   7.70804822e-01]
   [  1.00458902e-03   2.89083156e-03   7.80284464e-01]]

  [[  9.46218672e-04   3.41471168e-03   7.12520182e-01]
   [  1.05738617e-03   3.51133919e-03   7.37544417e-01]
   [  1.11490267e-03   3.50734987e-03   7.59527028e-01]
   [  1.09690335e-03   3.39841680e-03   7.76843786e-01]
   [  1.02025538e-03   3.22798942e-03   7.89109111e-01]]

  ..., 
  [[  1.31674367e-03   2.94192275e-03   8.54592204e-01]
   [  1.33714825e-03   1.93314103e-03   8.52739155e-01]
   [  1.26935216e-03   7.71999534e-04   8.47336113e-01]
   [  1.12190272e-03   2.73687299e-04   8.37770700e-01]
   [  9.42288549e-04   1.00770115e-03   8.24078143e-01]]

  [[  1.16831844e-03   5.54113230e-03   7.73506105e-01]
   [  1.19426579e-03   4.34003165e-03   7.72892058e-01]
   [  1.14343094e-03   2.87556089e-03   7.69116223e-01]
   [  1.02060486e-03   1.48697628e-03   7.61494219e-01]
   [  8.66071729e-04   4.54419031e-04   7.50091732e-01]]

  [[  1.03593292e-03   6.61619240e-03   6.99135602e-01]
   [  1.07749773e-03   5.38318930e-03   7.02196956e-01]
   [  1.05211872e-03   3.81015358e-03   7.02283561e-01]
   [  9.58701072e-04   2.26876861e-03   6.98524058e-01]
   [  8.30203935e-04   1.09007047e-03   6.90948009e-01]]]


 ..., 
 [[[  1.64938194e-03   5.15423999e-05   8.00862670e-01]
   [  1.78180530e-03   2.68631353e-04   8.02298009e-01]
   [  1.81128853e-03   4.80874471e-04   8.03299010e-01]
   [  1.71770272e-03   6.38028665e-04   8.03436279e-01]
   [  1.54292549e-03   7.18564435e-04   8.02370906e-01]]

  [[  1.59878796e-03   1.81043069e-04   7.83075333e-01]
   [  1.72957801e-03   6.33472286e-04   7.89788246e-01]
   [  1.75604224e-03   1.14124571e-03   7.95796096e-01]
   [  1.65938004e-03   1.58887194e-03   8.00549865e-01]
   [  1.48274947e-03   1.89499557e-03   8.03654432e-01]]

  [[  1.48419430e-03   6.38593337e-04   7.66206264e-01]
   [  1.61770580e-03   1.59773424e-06   7.76779532e-01]
   [  1.65090291e-03   7.69902719e-04   7.86304235e-01]
   [  1.56422332e-03   1.50141038e-03   7.94303715e-01]
   [  1.39849808e-03   2.04688730e-03   8.00486624e-01]]

  ..., 
  [[  1.24468841e-03   1.52818291e-04   7.00643957e-01]
   [  1.38457492e-03   4.54035529e-04   7.29066432e-01]
   [  1.45086972e-03   1.25358230e-03   7.58146167e-01]
   [  1.41761277e-03   2.08802731e-03   7.85211146e-01]
   [  1.31001428e-03   2.78623099e-03   8.08083713e-01]]

  [[  1.22181803e-03   1.75262999e-03   7.12200224e-01]
   [  1.35582569e-03   2.46245158e-03   7.33613491e-01]
   [  1.41868740e-03   3.34730162e-03   7.55082250e-01]
   [  1.38596492e-03   4.22661798e-03   7.74798095e-01]
   [  1.28191384e-03   4.92744986e-03   7.91277945e-01]]

  [[  1.23074406e-03   3.15821939e-03   7.25249112e-01]
   [  1.34763541e-03   3.67199560e-03   7.35695243e-01]
   [  1.39258499e-03   4.27761674e-03   7.45740950e-01]
   [  1.34575751e-03   4.84080054e-03   7.54573822e-01]
   [  1.23361498e-03   5.25227608e-03   7.61517644e-01]]]


 [[[  1.55793829e-03   2.16672546e-03   8.43835473e-01]
   [  1.68960961e-03   1.64857076e-03   8.41370463e-01]
   [  1.72065746e-03   1.03472290e-03   8.38117361e-01]
   [  1.63103652e-03   4.62091615e-04   8.34113836e-01]
   [  1.46155385e-03   4.04728853e-05   8.29389155e-01]]

  [[  1.55008328e-03   1.89458346e-03   8.36009026e-01]
   [  1.68013258e-03   1.14960445e-03   8.37347388e-01]
   [  1.70591671e-03   2.58495769e-04   8.37396979e-01]
   [  1.60896382e-03   5.76604798e-04   8.36158216e-01]
   [  1.43262709e-03   1.19205040e-03   8.33709419e-01]]

  [[  1.46983226e-03   1.89801212e-03   8.23029637e-01]
   [  1.60238694e-03   9.92891495e-04   8.27210605e-01]
   [  1.63295411e-03   1.09161039e-04   8.29748750e-01]
   [  1.54250674e-03   1.15490716e-03   8.30680788e-01]
   [  1.37307972e-03   1.93381449e-03   8.30179572e-01]]

  ..., 
  [[  1.47266500e-03   1.64773280e-03   7.51415670e-01]
   [  1.65975164e-03   1.77796243e-03   7.82547712e-01]
   [  1.75402453e-03   1.88937958e-03   8.13206196e-01]
   [  1.71964359e-03   1.97831425e-03   8.40966344e-01]
   [  1.58715714e-03   2.05266196e-03   8.64083052e-01]]

  [[  1.51997362e-03   3.70279537e-03   7.61539459e-01]
   [  1.70740695e-03   3.97937279e-03   7.86999702e-01]
   [  1.79891137e-03   4.24418598e-03   8.11793745e-01]
   [  1.75897859e-03   4.45796922e-03   8.34062815e-01]
   [  1.61949149e-03   4.60533518e-03   8.52440953e-01]]

  [[  1.56895816e-03   4.56609763e-03   7.64674306e-01]
   [  1.74151140e-03   4.80762217e-03   7.81955242e-01]
   [  1.81455608e-03   5.02518285e-03   7.98543334e-01]
   [  1.75680988e-03   5.17545082e-03   8.13137710e-01]
   [  1.60356658e-03   5.24611678e-03   8.24743271e-01]]]


 [[[  1.52400800e-03   3.90013075e-03   8.88753533e-01]
   [  1.63972634e-03   3.13989399e-03   8.81006062e-01]
   [  1.65387266e-03   2.20846268e-03   8.72219145e-01]
   [  1.55115745e-03   1.31227868e-03   8.62843871e-01]
   [  1.37510337e-03   6.28432957e-04   8.53265226e-01]]

  [[  1.55285222e-03   3.73305264e-03   8.88114691e-01]
   [  1.66715437e-03   2.78906384e-03   8.83200943e-01]
   [  1.67474966e-03   1.63759664e-03   8.76693487e-01]
   [  1.56188861e-03   5.38774242e-04   8.68969679e-01]
   [  1.37539569e-03   2.89099815e-04   8.60457301e-01]]

  [[  1.49823364e-03   3.18208919e-03   8.77158284e-01]
   [  1.61604711e-03   2.14182492e-03   8.74414086e-01]
   [  1.62852474e-03   8.73714860e-04   8.69743586e-01]
   [  1.52107480e-03   3.30202980e-04   8.63500416e-01]
   [  1.33955048e-03   1.22798583e-03   8.56163681e-01]]

  ..., 
  [[  1.79291586e-03   3.57511919e-03   7.91196167e-01]
   [  2.02018255e-03   3.01371049e-03   8.20244610e-01]
   [  2.12479034e-03   2.15981994e-03   8.48378181e-01]
   [  2.06440850e-03   1.22949807e-03   8.73734236e-01]
   [  1.88174879e-03   4.68988204e-04   8.95016134e-01]]

  [[  1.92916463e-03   5.67821506e-03   8.06897998e-01]
   [  2.16552662e-03   5.27410628e-03   8.31389964e-01]
   [  2.26868596e-03   4.60254867e-03   8.54745805e-01]
   [  2.19512125e-03   3.83779313e-03   8.75464320e-01]
   [  1.99203473e-03   3.18947108e-03   8.92521024e-01]]

  [[  2.02487386e-03   5.87538164e-03   8.08266819e-01]
   [  2.25249492e-03   5.66713372e-03   8.27256799e-01]
   [  2.33987742e-03   5.26776677e-03   8.45021486e-01]
   [  2.24642386e-03   4.77599027e-03   8.60318363e-01]
   [  2.02394277e-03   4.32666671e-03   8.72307003e-01]]]]

In [50]:
fvtk.add(ren, fvtk.tensor(evals, evecs, cfa, sphere))

In [51]:
from IPython.display import Image
def vtk_show(renderer, width=400, height=300):
    """
    Takes vtkRenderer instance and returns an IPython Image with the rendering.
    """
    renderWindow = vtk.vtkRenderWindow()
    renderWindow.SetOffScreenRendering(1)
    renderWindow.AddRenderer(renderer)
    renderWindow.SetSize(width, height)
    renderWindow.Render()
     
    windowToImageFilter = vtk.vtkWindowToImageFilter()
    windowToImageFilter.SetInput(renderWindow)
    windowToImageFilter.Update()
     
    writer = vtk.vtkPNGWriter()
    writer.SetWriteToMemory(1)
    writer.SetInputConnection(windowToImageFilter.GetOutputPort())
    writer.Write()
    data = str(buffer(writer.GetResult()))
    
    return Image(data)

Results:


In [52]:
# x = 4250:4300, y = 250:300, z = : on Tony's computer (doesn't show anything)
# Thus, all results were displayed after running on Albert's computer
vtk_show(ren)


Out[52]:

x = [0, 25], y = [25, 50] (different views):

View 1:

View 2:

View 3:

View 4:

View 5:

View 6:

raw 1:

x = [1000, 1025], y = [1025, 1050] (different views):

View 1:

View 2:

View 3:

View 4:

raw 2:

x = [4025, 4050], y = [250, 300] (different views):

View 1:

View 2:

View 3:

View 4:

View 5:

raw 3: